import java.util.*;
class StudentKey implements Comparable {
	double d=0;
	String s="";
	StudentKey (double d) {
		this.d=d;
	}
	StudentKey (String s) {
		this.s=s;
	}
	public int compareTo(Object b) {
		StudentKey st=(StudentKey)b;
		if((this.d-st.d)==0)
			return -1;
		else
			return (int)((this.d-st.d)*1000);
	}
}
class StudentIF {
	String name=null;
	String number = null;
	double math,english,computer,total,aver;
	StudentIF(String s,String num, double m, double e, double f, double a,double b) {
		name=s;
		number = num;
		math=m;
		english=e;
		computer=f;
		total=a;
		aver=b;
	}
}
public class TestScore {
	public static void main(String args[]) {
		TreeMap<StudentKey, StudentIF> treemap = new TreeMap<StudentKey, StudentIF>();
		String str[] = {"xuwen", "lijiaxin", "caoge", "zhangchenhui", "chenyouzhang"};
		String number[] = {"20165310","20165311","20165312","20165313","20165314","20165315"};
		double math[] = {89, 45, 78, 76, 60};
		double english[] = {67, 68, 100, 30, 71};
		double computer[] = {76, 40, 30, 90, 80};
		double total[] = new double[5];
		double aver[] = new double[5];
		StudentIF student[] = new StudentIF[5];
		for (int k = 0; k < student.length; k++) {
			total[k] = math[k] + english[k] + computer[k];
			aver[k] = total[k] / 3;
		}
		for (int k = 0; k < student.length; k++) {
			student[k] = new StudentIF(str[k],number[k], math[k], english[k], computer[k], total[k], aver[k]);
		}
		StudentKey key[] = new StudentKey[5];
		for (int k = 0; k < key.length; k++) {
			key[k] = new StudentKey(student[k].total);
		}
		for (int k = 0; k < student.length; k++) {
			treemap.put(key[k], student[k]);
		}
		int a = treemap.size();
		System.out.println("一共有" + a + "个同学,按总成绩排序:");
		Collection<StudentIF> collection = treemap.values();
		Iterator<StudentIF> iter = collection.iterator();
		while (iter.hasNext()) {
			StudentIF stu = iter.next();
			System.out.println("学号"+stu.number +"姓名 " + stu.name + " 总成绩 " + stu.total);
		}
	}
}
